home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / tcl.vim < prev    next >
Encoding:
Text File  |  2001-05-10  |  14.2 KB  |  232 lines

  1. " Vim syntax file
  2. " Language:    TCL/TK
  3. " Maintainer:    Matt Neumann <mattneu@purpleturtle.com>
  4. "        (previously Allan Kelly <allan@fruitloaf.co.uk>)
  5. " Original:    Robin Becker <robin@jessikat.demon.co.uk>
  6. " Version:    5.1(synched), 1998 June 29
  7. "
  8. " Keywords TODO: format clock click anchor
  9.  
  10. " For version 5.x: Clear all syntax items
  11. " For version 6.x: Quit when a syntax file was already loaded
  12. if version < 600
  13.   syntax clear
  14. elseif exists("b:current_syntax")
  15.   finish
  16. endif
  17.  
  18. " A bunch of useful keywords
  19. syn keyword tclStatement    proc global return lindex
  20. syn keyword tclStatement    llength lappend lreplace lrange list concat incr
  21. syn keyword tclStatement    upvar set
  22. syn keyword tclLabel        case default
  23. syn keyword tclConditional    if then else elseif switch
  24. syn keyword tclRepeat        while for foreach break continue
  25. syn keyword tcltkSwitch    contained    insert create polygon fill outline tag
  26.  
  27. " WIDGETS
  28. " commands associated with widgets
  29. syn keyword tcltkWidgetSwitch contained background highlightbackground insertontime cget
  30. syn keyword tcltkWidgetSwitch contained selectborderwidth borderwidth highlightcolor insertwidth
  31. syn keyword tcltkWidgetSwitch contained selectforeground cursor highlightthickness padx setgrid
  32. syn keyword tcltkWidgetSwitch contained exportselection insertbackground pady takefocus
  33. syn keyword tcltkWidgetSwitch contained font insertborderwidth relief xscrollcommand
  34. syn keyword tcltkWidgetSwitch contained foreground insertofftime selectbackground yscrollcommand
  35. syn keyword tcltkWidgetSwitch contained height spacing1 spacing2 spacing3
  36. syn keyword tcltkWidgetSwitch contained state tabs width wrap
  37. " button
  38. syn keyword tcltkWidgetSwitch contained command default
  39. " canvas
  40. syn keyword tcltkWidgetSwitch contained closeenough confine scrollregion xscrollincrement yscrollincrement orient
  41. " checkbutton, radiobutton
  42. syn keyword tcltkWidgetSwitch contained indicatoron offvalue onvalue selectcolor selectimage state variable
  43. " entry, frame
  44. syn keyword tcltkWidgetSwitch contained show class colormap container visual
  45. " listbox, menu
  46. syn keyword tcltkWidgetSwitch contained selectmode postcommand selectcolor tearoff tearoffcommand title type
  47. " menubutton, message
  48. syn keyword tcltkWidgetSwitch contained direction aspect justify
  49. " scale
  50. syn keyword tcltkWidgetSwitch contained bigincrement digits from length resolution showvalue sliderlength sliderrelief tickinterval to
  51. " scrollbar
  52. syn keyword tcltkWidgetSwitch contained activerelief elementborderwidth
  53. " image
  54. syn keyword tcltkWidgetSwitch contained delete names types create
  55. " variable reference
  56. syn match tclVarRef "$\a[a-zA-Z0-9_.]*"
  57. syn match tclVarRef "${\a[a-zA-Z0-9_.]*}"
  58. " menu, mane add
  59. syn keyword tcltkWidgetSwitch contained active end last none cascade checkbutton command radiobutton separator
  60. syn keyword tcltkWidgetSwitch contained activebackground actveforeground accelerator background bitmap columnbreak
  61. syn keyword tcltkWidgetSwitch contained font foreground hidemargin image indicatoron label menu offvalue onvalue
  62. syn keyword tcltkWidgetSwitch contained selectcolor selectimage state underline value variable
  63. syn keyword tcltkWidgetSwitch contained add clone configure delete entrycget entryconfigure index insert invoke
  64. syn keyword tcltkWidgetSwitch contained post postcascade type unpost yposition activate
  65. "syn keyword tcltkWidgetSwitch contained
  66. "syn match tcltkWidgetSwitch contained
  67. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<button\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  68. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scale\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  69.  
  70. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<canvas\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  71. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<checkbutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  72. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<entry\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  73. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<frame\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  74. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<image\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  75. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<listbox\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  76. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<menubutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  77. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<message\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  78. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<radiobutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  79. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scrollbar\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  80. " These words are dual purpose.
  81. " match switches
  82. syn match tcltkWidgetSwitch contained "-text"hs=s+1
  83. syn match tcltkWidgetSwitch contained "-menu"hs=s+1
  84. syn match tcltkWidgetSwitch contained "-label"hs=s+1
  85. " match commands - 2 lines for pretty match.
  86. "variable
  87. " Special case - If a number follows a variable region, it must be at the end of
  88. " the pattern, by definition. Therefore, (1) either include a number as the region
  89. " end and exclude tclNumber from the contains list, or (2) make variable
  90. " keepend. As (1) would put variable out of step with everything else, use (2).
  91. syn region tcltkCommand matchgroup=tcltkCommandColor start="^\<variable\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
  92. syn region tcltkCommand matchgroup=tcltkCommandColor start="\s\<variable\>\|\[\<variable\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
  93. " menu
  94. syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<menu\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  95. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<menu\>\|\[\<menu\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  96. " label
  97. syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<label\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  98. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<label\>\|\[\<label\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  99. " text
  100. syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<text\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tcltkSwitch,tclNumber,tclVarRef,tclString
  101. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<text\>\|\[\<text\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
  102.  
  103. " This isn't contained (I don't think) so it's OK to just associate with the Color group.
  104. " TODO: This could be wrong.
  105. syn keyword tcltkWidgetColor    toplevel
  106.  
  107.  
  108. syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<configure\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef keepend
  109. syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<cget\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef
  110.  
  111.  
  112. " NAMESPACE
  113. " commands associated with namespace
  114. syn keyword tcltkNamespaceSwitch contained children code current delete eval
  115. syn keyword tcltkNamespaceSwitch contained export forget import inscope origin
  116. syn keyword tcltkNamespaceSwitch contained parent qualifiers tail which command variable
  117. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<namespace\>" matchgroup=NONE skip="^\s*$" end="{\|}\|]\|\"\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkNamespaceSwitch
  118.  
  119. " EXPR
  120. " commands associated with expr
  121. syn keyword tcltkMaths    contained    acos    cos    hypot    sinh
  122. syn keyword tcltkMaths    contained    asin    cosh    log    sqrt
  123. syn keyword tcltkMaths    contained    atan    exp    log10    tan
  124. syn keyword tcltkMaths    contained    atan2    floor    pow    tanh
  125. syn keyword tcltkMaths    contained    ceil    fmod    sin
  126. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<expr\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf
  127.  
  128. " format
  129. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<format\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf
  130.  
  131. " PACK
  132. " commands associated with pack
  133. syn keyword tcltkPackSwitch    contained    forget info propogate slaves
  134. syn keyword tcltkPackConfSwitch    contained    after anchor before expand fill in ipadx ipady padx pady side
  135. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<pack\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkPackSwitch,tcltkPackConf,tcltkPackConfSwitch,tclNumber,tclVarRef,tclString,tcltkCommand keepend
  136.  
  137. " STRING
  138. " commands associated with string
  139. syn keyword tcltkStringSwitch    contained    compare first index last length match range tolower toupper trim trimleft trimright wordstart wordend
  140. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<string\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkStringSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
  141.  
  142. " ARRAY
  143. " commands associated with array
  144. syn keyword tcltkArraySwitch    contained    anymore donesearch exists get names nextelement size startsearch set
  145. " match from command name to ] or EOL
  146. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<array\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkArraySwitch,tclNumber,tclVarRef,tclString,tcltkCommand
  147.  
  148. " LSORT
  149. " switches for lsort
  150. syn keyword tcltkLsortSwitch    contained    ascii dictionary integer real command increasing decreasing index
  151. " match from command name to ] or EOL
  152. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<lsort\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkLsortSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
  153.  
  154. syn keyword tclTodo contained    TODO
  155.  
  156.  
  157. " String and Character contstants
  158. " Highlight special characters (those which have a backslash) differently
  159. syn match   tclSpecial contained "\\\d\d\d\=\|\\."
  160. " A string needs the skip argument as it may legitimately contain \".
  161. " Match at start of line
  162. syn region  tclString          start=+^"+ end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
  163. "Match all other legal strings.
  164. syn region  tclString          start=+[^\\]"+ms=s+1  end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
  165.  
  166. syn match   tclLineContinue "\\\s*$"
  167.  
  168. "integer number, or floating point number without a dot and with "f".
  169. syn case ignore
  170. syn match  tclNumber        "\<\d\+\(u\=l\=\|lu\|f\)\>"
  171. "floating point number, with dot, optional exponent
  172. syn match  tclNumber        "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
  173. "floating point number, starting with a dot, optional exponent
  174. syn match  tclNumber        "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
  175. "floating point number, without dot, with exponent
  176. syn match  tclNumber        "\<\d\+e[-+]\=\d\+[fl]\=\>"
  177. "hex number
  178. syn match  tclNumber        "0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
  179. "syn match  tclIdentifier    "\<[a-z_][a-z0-9_]*\>"
  180. syn case match
  181.  
  182. syn region  tclComment        start="^\s*\#" end="$" contains=tclTodo
  183. syn region  tclComment        start=/;\s*\#/hs=s+1 end="$" contains=tclTodo
  184.  
  185. "syn sync ccomment tclComment
  186.  
  187. " Define the default highlighting.
  188. " For version 5.7 and earlier: only when not done already
  189. " For version 5.8 and later: only when an item doesn't have highlighting yet
  190. if version >= 508 || !exists("did_tcl_syntax_inits")
  191.   if version < 508
  192.     let did_tcl_syntax_inits = 1
  193.     command -nargs=+ HiLink hi link <args>
  194.   else
  195.     command -nargs=+ HiLink hi def link <args>
  196.   endif
  197.  
  198.   HiLink tcltkSwitch        Special
  199.   HiLink tclLabel        Label
  200.   HiLink tclConditional        Conditional
  201.   HiLink tclRepeat        Repeat
  202.   HiLink tclNumber        Number
  203.   HiLink tclError        Error
  204.   HiLink tclStatement        Statement
  205.   "HiLink tclStatementColor    Statement
  206.   HiLink tclString        String
  207.   HiLink tclComment        Comment
  208.   HiLink tclSpecial        Special
  209.   HiLink tclTodo        Todo
  210.   " Below here are the commands and their options.
  211.   HiLink tcltkCommandColor    Statement
  212.   HiLink tcltkWidgetColor      Structure
  213.   HiLink tclLineContinue       WarningMsg
  214.   HiLink tcltkStringSwitch    Special
  215.   HiLink tcltkArraySwitch    Special
  216.   HiLink tcltkLsortSwitch    Special
  217.   HiLink tcltkPackSwitch    Special
  218.   HiLink tcltkPackConfSwitch    Special
  219.   HiLink tcltkMaths        Special
  220.   HiLink tcltkNamespaceSwitch    Special
  221.   HiLink tcltkWidgetSwitch    Special
  222.   HiLink tcltkPackConfColor    Identifier
  223.   "HiLink tcltkLsort        Statement
  224.   HiLink tclVarRef             Identifier
  225.  
  226.   delcommand HiLink
  227. endif
  228.  
  229. let b:current_syntax = "tcl"
  230.  
  231. " vim: ts=8
  232.